<script>
import { h } from "vue";
export default {
  name: "RenderTest",
  props: {
    counter: {
      type: Number,
      default: 0,
    },
  },
  emits: ["update:counter"],
  methods: {
    onClick() {
      this.$emit("update:counter", this.counter + 1);
    },
  },
  render() {
    // 废除作用域插槽
    this.$slots.default();
    this.$slots.content();
    return h("div", [
      h(
        "div",
        {
          style: { cursor: "pointer" },
          onClick: this.onClick,
        },
        [
          `调用render函数创建的组件: ${this.counter}`,
          this.$slots.default(),
          this.$slots.content(),
        ]
      ),
    ]);
  },
};
</script>
